package com.bw2102a.config;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

@Configuration
public class OssConfig {

    // 区域
    @Value("${aliyun.oss.endpoint}")
    private String endpoint;

    // 桶名称
    @Value("${aliyun.oss.bucketName}")
    private String bucketName;

    // key
    @Value("${aliyun.oss.accessKeyId}")
    private String accessKeyId;

    // 密钥
    @Value("${aliyun.oss.accessKeySecret}")
    private String accessKeySecret;


    @Bean
    public OSS ossClientBuilder(){
        OSS ossClientBuilder = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
        return ossClientBuilder;
    }

}
